﻿using Mes.Domain.BoundedContext.Entities.WorkOrders;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Mes.Infrastructure.Data.BoundedContext.EntityTypeConfigurations.WorkOrders
{
    public class JobBomStepEntityConfig : IEntityTypeConfiguration<JobBomStep>
    {
        public void Configure(EntityTypeBuilder<JobBomStep> builder)
        {
            builder.ToTable("job_bom_step");
            builder.HasKey(b => new { b.Wo_Id,b.Oper_Id,b.Bom_Pos,b.Step_Grp_Id,b.Step_No });
            builder.Property(b => b.Wo_Id).HasMaxLength(40).IsRequired();
            builder.Property(b => b.Oper_Id).HasMaxLength(40).IsRequired();
            builder.Property(b => b.Bom_Pos).IsRequired();
            builder.Property(b => b.Step_Grp_Id).IsRequired();
            builder.Property(b => b.Step_No).IsRequired();
            builder.Property(b => b.Qty_Per_Parent_Item).IsRequired();
            builder.Property(b => b.Last_Edit_Comment).HasMaxLength(254);
            builder.Property(b => b.Last_Edit_By).HasMaxLength(40);
            builder.Property(b => b.Last_Edit_At).IsRequired();
            builder.Property(b => b.Mod_Id).IsRequired();
            builder.Property(b => b.Row_Id).IsRequired().UseIdentityColumn().HasIdentityOptions(startValue: 0, incrementBy: 1, minValue: 0);
        }
    }
}
